<script lang="ts" setup>
import { http } from "@/utils/http";
import { onMounted, ref, unref, computed } from "vue";
import { useLoginAccountStoreWithOut } from '@/store/modules/login'

import { useSettings } from '@/layout/hooks/useSettings'
const { getHeaderColor } = useSettings()
const isHeaderbgWhite = computed(
  (): boolean => unref(getHeaderColor) === '#ffffff'
)

const loginAccountStore = useLoginAccountStoreWithOut()

const approvalIcon = ref(['far', 'bell']);
const fixedAssetsIcon = ref(['fas', 'desktop']);
const freeAssetsIcon = ref(['fas', 'toilet-paper']);
const userIcon = ref(['far', 'user']);

const approvalCount = ref()
const fixedAssetsCount = ref()
const freeAssetsCount = ref()
const userCount = ref()

const newApprovalCount = ref()
const newFixedAssetsCount = ref()
const newFreeAssetsCount = ref()
const newUserCount = ref()

</script>

<template>
  <div class="layout-wrapper">
    <div class="layout-container">
      <div class="layout-main">
        <div class="grid">
          <div class="col-12 lg:col-6 xl:col-3">
            <div class="card mb-0" :class="[
      unref(isHeaderbgWhite) ? 'card-light' : 'card-unlight'
    ]">
              <div class="flex justify-content-between mb-3">
                <div>                  
                  <span class="block text-500 font-medium mb-3">审批</span>
                  <div id="t1" class="font-medium text-xl">{{ approvalCount }}</div>
                </div>
                <div class="flex align-items-center justify-content-center bg-blue-100 border-round"
                  style="width:2.5rem;height:2.5rem">
                  <FontAwesomeIcon :icon="approvalIcon" class="text-blue-500" size="lg" />
                </div>
              </div>
              <span class="text-green-500 font-medium">{{ newApprovalCount }} new </span>
              <div id="anchor1" class="anchor"></div>
              <span class="text-500">since last visit</span>
            </div>            
          </div>

          <div class="col-12 lg:col-6 xl:col-3">
            <div class="card mb-0" :class="[
      unref(isHeaderbgWhite) ? 'card-light' : 'card-unlight'
    ]">
              <div class="flex justify-content-between mb-3">
                <div>
                  <span class="block text-500 font-medium mb-3">固定资产</span>
                  <div id="t2" class="font-medium text-xl">{{ fixedAssetsCount }}</div>
                </div>
                <div class="flex align-items-center justify-content-center bg-orange-100 border-round"
                  style="width:2.5rem;height:2.5rem">
                  <FontAwesomeIcon :icon="fixedAssetsIcon" class="text-orange-500" size="lg" />
                </div>
              </div>
              <span class="text-green-500 font-medium">{{ newFixedAssetsCount }} new </span>
              <span class="text-500">since last visit</span>
            </div>
          </div>

          <div class="col-12 lg:col-6 xl:col-3">
            <div class="card mb-0" :class="[
      unref(isHeaderbgWhite) ? 'card-light' : 'card-unlight'
    ]">
              <div class="flex justify-content-between mb-3">
                <div>
                  <span class="block text-500 font-medium mb-3">易耗品资产</span>
                  <div id="t3" class="font-medium text-xl">{{ freeAssetsCount }}</div>
                </div>
                <div class="flex align-items-center justify-content-center bg-cyan-100 border-round"
                  style="width:2.5rem;height:2.5rem">
                  <FontAwesomeIcon :icon="freeAssetsIcon" class="text-cyan-500" size="lg" />
                </div>
              </div>
              <span class="text-green-500 font-medium">{{ newFreeAssetsCount }} new </span>
              <span class="text-500">since last visit</span>
            </div>
          </div>

          <div class="col-12 lg:col-6 xl:col-3">
            <div class="card mb-0" :class="[
      unref(isHeaderbgWhite) ? 'card-light' : 'card-unlight'
    ]">
              <div class="flex justify-content-between mb-3">
                <div>
                  <span class="block text-500 font-medium mb-3">用户</span>
                  <div id="t4" class="font-medium text-xl">{{ userCount }}</div>
                </div>
                <div class="flex align-items-center justify-content-center bg-purple-100 border-round"
                  style="width:2.5rem;height:2.5rem">
                  <FontAwesomeIcon :icon="userIcon" class="text-purple-500" size="lg" />
                </div>
              </div>
              <span class="text-green-500 font-medium">{{ newUserCount }} new </span>
              <span class="text-500">since last visit</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>  
</template>

<style lang="less" scoped>
@import '@/layout/style/theme.less';
</style>

<style scoped>
* {
  box-sizing: border-box;
}

div {
  display: block;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
  color: #495057;
  background-color: #eff3f8;
  margin: 0;
  padding: 0;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

@media (min-width: 992px) {
  .layout-wrapper .layout-container {
    margin-left: 0px;
  }
}

@media (max-width: 991px) {
  .layout-wrapper .layout-container {
    margin-left: 0;
    padding-left: 2rem;
  }
}

.layout-container{
  display: flex;
  flex-direction: column;  
  justify-content: space-between;
  padding: 2rem 2rem 1rem 2rem;
  transition: margin-left 0.2s;
}

.layout-main{
  flex: 1 1 auto;
}

.grid{
  display: flex;
  flex-wrap: wrap;
  margin-right: -0.5rem;
  margin-left: -0.5rem;
  margin-top: -0.5rem;
}

.grid > .col, .grid > [class*=col] {
  box-sizing: border-box;
}

@media screen and (min-width: 992px) {
  .lg\:col-6 {    
      flex: 0 0 auto;
      padding: 0.5rem;
      width: 50%;
    }
}

@media screen and (max-width: 991px) {
  .col-12 {
    flex: 0 0 auto;
    padding: 0.5rem;
    width: 100%;
  }
}

@media screen and (min-width: 1200px) {
  .xl\:col-3 {
    flex: 0 0 auto;
    padding: 0.5rem;
    width: 25%;
  }
}

.card {  
  padding: 1.5rem;  
  margin-bottom: 1rem;
  border-radius: 12px;    
}

.mb-0 {
  margin-bottom: 0rem !important;
}

.mb-3 {
  margin-bottom: 1rem !important;  
}

.justify-content-between {
  justify-content: space-between !important;
}

.flex {
  display: flex !important;
}

.block {
  display: block !important;
}

.text-xl {
  font-size: 1.25rem !important;
}

.border-round {
  border-radius: 6px !important;
}

.align-items-center {
  align-items: center !important;
}

.justify-content-center {
  justify-content: center !important;
}

.bg-blue-100 {
  background-color: #d0e1fd !important;
}

.text-blue-500 {
  color: #3b82f6 !important;
}

.bg-orange-100 {
  background-color: #feddc7 !important;
}

.text-orange-500 {
  color: #f97316 !important;
}

.bg-cyan-100 {
  background-color: #c3edf5 !important;
}

.text-cyan-500 {
  color: #06b6d4 !important;
}

.bg-purple-100 {
  background-color: #ead6fd !important;
}

.text-purple-500 {
  color: #a855f7 !important;
}

.font-medium {
  font-weight: 500 !important;
}

.text-green-500 {
  color: #22c55e !important;
}

.text-500 {
  color: #9e9e9e !important;
}

.anchor {
  position: fixed;
  margin: -10px 0 0 0;
  width: 20px;
  height: 20px;
  font-size: 1.2em;
  font-weight: 500;
  transform: translate(-50%, -50%);
  transition: 1s ease-in, opacity 0.7s ease-in 0.3s;
  color: #22c55e;
}

#anchor1, 
#anchor2, 
#anchor3, 
#anchor4{
  display: inline;
  z-index: 999;
}
</style>